package sistemasdistribuidos;

import java.awt.event.KeyEvent;
import telasMensagem.bloqueio;
import telasMensagem.simNao;

public class fecharVenda extends javax.swing.JDialog {

    double falta = 0;
    double troco = 0;
    double recebido = 0;
    static double total;

    public fecharVenda(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    public fecharVenda(java.awt.Frame parent, boolean modal, double total) {
        super(parent, modal);
        initComponents();
        falta = total;
        this.total = total;
        String valor = String.valueOf(total);
        jTextFieldFalta.setText(valor);
        jTextFieldTotal.setText(valor);
    }

    public void contas(double pega) {
        try {
            recebido = pega + recebido;
            falta = falta - pega;
            jTextFieldRecebido.setText(String.valueOf(recebido));
            if (falta < 1) {
                falta = 0;
                jTextFieldFalta.setText("0.00");
            }
            if (recebido > total) {
                troco = (recebido - total);
                jTextFieldTroco.setText(String.valueOf(troco));
            } else {
                jTextFieldFalta.setText(String.valueOf(falta));
            }
        } catch (Exception ex) {
            bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                    + " separando os centavo por ponto (`.`)</html>");
            bl.setLocationRelativeTo(null);
            bl.setVisible(true);
        }
    }

    public void apagar(Double retirado) {

        if (retirado >= troco) {
            troco = 0;
            jTextFieldTroco.setText("0.00");
        } else {
            troco = troco - retirado;
            jTextFieldTroco.setText(String.valueOf(troco));
        }
        recebido = recebido - retirado;
        jTextFieldRecebido.setText(String.valueOf(recebido));
        if (retirado == recebido) {
            falta = total;
        } else {
            if (recebido > total) {
                falta = -1 * (total - recebido);
            } else {
                falta = total - recebido;
            }
        }
        if (recebido > total) {
            falta = 0;
        }
        jTextFieldFalta.setText(String.valueOf(falta));
    }

    public static void limpar() {
        jTextFieldCheque.setEditable(true);
        jTextFieldCheque.setText("0.00");
        jTextFieldCredito.setEditable(true);
        jTextFieldCredito.setText("0.00");
        jTextFieldDinheiro.setEditable(true);
        jTextFieldDinheiro.setText("0.00");
        jTextFieldDebito.setEditable(true);
        jTextFieldDebito.setText("0.00");
        jTextFieldFalta.setText(String.valueOf(total));
        jTextFieldRecebido.setText("0.00");
        jTextFieldTroco.setText("0.00");
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabelMsg7 = new javax.swing.JLabel();
        jLabelMsg8 = new javax.swing.JLabel();
        jLabelMsg10 = new javax.swing.JLabel();
        jLabelMsg18 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabelMsg3 = new javax.swing.JLabel();
        jLabelMsg5 = new javax.swing.JLabel();
        jTextFieldFalta = new javax.swing.JTextField();
        jTextFieldRecebido = new javax.swing.JTextField();
        jLabelMsg4 = new javax.swing.JLabel();
        jTextFieldTotal = new javax.swing.JTextField();
        jLabelMsg2 = new javax.swing.JLabel();
        jTextFieldTroco = new javax.swing.JTextField();
        jButtonLimparDados = new javax.swing.JButton();
        jButtonCancelarCadastro = new javax.swing.JButton();
        jButtonConcluir = new javax.swing.JButton();
        jButtonApagarCredito = new javax.swing.JButton();
        jButtonApagarCheque = new javax.swing.JButton();
        jButtonApagarDebito = new javax.swing.JButton();
        jButtonApagarDinheiro = new javax.swing.JButton();
        jTextFieldDinheiro = new javax.swing.JTextField();
        jTextFieldCheque = new javax.swing.JTextField();
        jTextFieldDebito = new javax.swing.JTextField();
        jTextFieldCredito = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Fechar Vendas");
        setAlwaysOnTop(true);

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0)), "Valores Recebidos", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel1.setToolTipText("");

        jPanel3.setBackground(new java.awt.Color(255, 102, 0));
        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabelMsg7.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg7.setText("Dinheiro:");

        jLabelMsg8.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg8.setText("Cheque:");

        jLabelMsg10.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg10.setText("Cartão Crédito:");

        jLabelMsg18.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg18.setText("Cartão Débito:");

        jPanel4.setBackground(new java.awt.Color(255, 102, 0));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0)), "Valores Recebidos", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 1, 14), new java.awt.Color(0, 0, 0))); // NOI18N

        jLabelMsg3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg3.setText("Falta:");

        jLabelMsg5.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg5.setText("Recebido:");

        jTextFieldFalta.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldFalta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldFaltaActionPerformed(evt);
            }
        });

        jTextFieldRecebido.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldRecebido.setText("0.00");

        jLabelMsg4.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg4.setText("Total:");

        jTextFieldTotal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N

        jLabelMsg2.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg2.setText("Troco:");

        jTextFieldTroco.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldTroco.setText("0.00");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTextFieldTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGap(0, 14, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelMsg3)
                                    .addComponent(jLabelMsg5)
                                    .addComponent(jLabelMsg4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldFalta, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldRecebido, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabelMsg2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTextFieldTroco, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg2)
                    .addComponent(jTextFieldTroco, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg5)
                    .addComponent(jTextFieldRecebido, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldFalta, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg4))
                .addContainerGap())
        );

        jButtonLimparDados.setBackground(new java.awt.Color(255, 255, 255));
        jButtonLimparDados.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonLimparDados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/limpar.png"))); // NOI18N
        jButtonLimparDados.setText("Limpar Pagamentos");
        jButtonLimparDados.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonLimparDados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimparDadosActionPerformed(evt);
            }
        });

        jButtonCancelarCadastro.setBackground(new java.awt.Color(255, 255, 255));
        jButtonCancelarCadastro.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonCancelarCadastro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/osso.png"))); // NOI18N
        jButtonCancelarCadastro.setText("Cancelar Pagamento");
        jButtonCancelarCadastro.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonCancelarCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarCadastroActionPerformed(evt);
            }
        });

        jButtonConcluir.setBackground(new java.awt.Color(255, 255, 255));
        jButtonConcluir.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonConcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonConcluir.setText("Concluir");
        jButtonConcluir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonConcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConcluirActionPerformed(evt);
            }
        });

        jButtonApagarCredito.setBackground(new java.awt.Color(255, 255, 255));
        jButtonApagarCredito.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonApagarCredito.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/x.png"))); // NOI18N
        jButtonApagarCredito.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonApagarCredito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonApagarCreditoActionPerformed(evt);
            }
        });

        jButtonApagarCheque.setBackground(new java.awt.Color(255, 255, 255));
        jButtonApagarCheque.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonApagarCheque.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/x.png"))); // NOI18N
        jButtonApagarCheque.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonApagarCheque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonApagarChequeActionPerformed(evt);
            }
        });

        jButtonApagarDebito.setBackground(new java.awt.Color(255, 102, 0));
        jButtonApagarDebito.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonApagarDebito.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/x.png"))); // NOI18N
        jButtonApagarDebito.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonApagarDebito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonApagarDebitoActionPerformed(evt);
            }
        });

        jButtonApagarDinheiro.setBackground(new java.awt.Color(255, 255, 255));
        jButtonApagarDinheiro.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonApagarDinheiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/x.png"))); // NOI18N
        jButtonApagarDinheiro.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonApagarDinheiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonApagarDinheiroActionPerformed(evt);
            }
        });

        jTextFieldDinheiro.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDinheiro.setText("0.00");
        jTextFieldDinheiro.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldDinheiroFocusLost(evt);
            }
        });
        jTextFieldDinheiro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldDinheiroKeyPressed(evt);
            }
        });

        jTextFieldCheque.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCheque.setText("0.00");
        jTextFieldCheque.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldChequeFocusLost(evt);
            }
        });
        jTextFieldCheque.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldChequeKeyPressed(evt);
            }
        });

        jTextFieldDebito.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDebito.setText("0.00");
        jTextFieldDebito.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldDebitoFocusLost(evt);
            }
        });
        jTextFieldDebito.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldDebitoKeyPressed(evt);
            }
        });

        jTextFieldCredito.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCredito.setText("0.00");
        jTextFieldCredito.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldCreditoFocusLost(evt);
            }
        });
        jTextFieldCredito.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldCreditoKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jButtonConcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButtonLimparDados, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jButtonCancelarCadastro, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(18, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg8)
                            .addComponent(jLabelMsg7))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldCheque, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonApagarCheque, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(11, 11, 11)
                                .addComponent(jTextFieldDinheiro, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonApagarDinheiro, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabelMsg18)
                            .addComponent(jLabelMsg10))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldDebito, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldCredito, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(7, 7, 7)
                                .addComponent(jButtonApagarDebito, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonApagarCredito, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonCancelarCadastro, jButtonConcluir, jButtonLimparDados});

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonApagarCheque, jButtonApagarCredito, jButtonApagarDebito, jButtonApagarDinheiro});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonApagarDebito, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelMsg18)
                        .addComponent(jTextFieldDebito, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabelMsg7)
                                .addComponent(jTextFieldDinheiro, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jButtonApagarDinheiro, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonApagarCheque, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldCheque, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelMsg8))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldCredito, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelMsg10))
                    .addComponent(jButtonApagarCredito, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jButtonLimparDados, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonCancelarCadastro)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonConcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonCancelarCadastro, jButtonLimparDados});

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextFieldFaltaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldFaltaActionPerformed

    }//GEN-LAST:event_jTextFieldFaltaActionPerformed

    private void jButtonLimparDadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimparDadosActionPerformed
        simNao sn = new simNao(null, true, "<html> Tem certeza que deseja"
                + " limpar as formas de pagamentos registradas? </html>", 1);
        sn.setLocationRelativeTo(null);
        sn.setVisible(true);
    }//GEN-LAST:event_jButtonLimparDadosActionPerformed

    private void jButtonCancelarCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarCadastroActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButtonCancelarCadastroActionPerformed

    private void jButtonConcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConcluirActionPerformed
        if (falta != 0) {
            bloqueio bl = new bloqueio(null, true, "<html>Complete o"
                    + " valor total da venda antes de concluí-la! <html>");
            bl.setLocationRelativeTo(null);
            bl.setVisible(true);

        } else {

            /*

             Salvar venda!!!!
             ********** Banco de Dados ***********

             */
        }
    }//GEN-LAST:event_jButtonConcluirActionPerformed

    private void jButtonApagarCreditoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApagarCreditoActionPerformed
        if (jTextFieldCredito.isEditable() == false) {
            apagar(Double.parseDouble(jTextFieldCredito.getText()));
            jTextFieldCredito.setEditable(true);
            jTextFieldCredito.setText("0.00");
        }
    }//GEN-LAST:event_jButtonApagarCreditoActionPerformed

    private void jButtonApagarChequeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApagarChequeActionPerformed
        if (jTextFieldCheque.isEditable() == false) {
            apagar(Double.parseDouble(jTextFieldCheque.getText()));
            jTextFieldCheque.setEditable(true);
            jTextFieldCheque.setText("0.00");
        }
    }//GEN-LAST:event_jButtonApagarChequeActionPerformed

    private void jButtonApagarDebitoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApagarDebitoActionPerformed
        if (jTextFieldDebito.isEditable() == false) {
            apagar(Double.parseDouble(jTextFieldDebito.getText()));
            jTextFieldDebito.setEditable(true);
            jTextFieldDebito.setText("0.00");
        }
    }//GEN-LAST:event_jButtonApagarDebitoActionPerformed

    private void jButtonApagarDinheiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApagarDinheiroActionPerformed
        if (jTextFieldDinheiro.isEditable() == false) {
            apagar(Double.parseDouble(jTextFieldDinheiro.getText()));
            jTextFieldDinheiro.setEditable(true);
            jTextFieldDinheiro.setText("0.00");
        }
    }//GEN-LAST:event_jButtonApagarDinheiroActionPerformed

    private void jTextFieldDinheiroKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldDinheiroKeyPressed
        if (jTextFieldDinheiro.isEditable() == true) {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                try {
                    double pegar = Double.valueOf(jTextFieldDinheiro.getText());
                    contas(pegar);
                    jTextFieldDinheiro.setEditable(false);
                } catch (Exception ex) {
                    bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                            + " separando os centavo por ponto (`.`)</html>");
                    bl.setLocationRelativeTo(null);
                    bl.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_jTextFieldDinheiroKeyPressed

    private void jTextFieldChequeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldChequeKeyPressed
        if (jTextFieldCheque.isEditable() == true) {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                try {
                    double pegar = Double.valueOf(jTextFieldCheque.getText());
                    contas(pegar);
                    jTextFieldCheque.setEditable(false);
                } catch (Exception ex) {
                    bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                            + " separando os centavo por ponto (`.`)</html>");
                    bl.setLocationRelativeTo(null);
                    bl.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_jTextFieldChequeKeyPressed

    private void jTextFieldDebitoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldDebitoKeyPressed
        if (jTextFieldDebito.isEditable() == true) {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                try {
                    double pegar = Double.valueOf(jTextFieldDebito.getText());
                    contas(pegar);
                    jTextFieldDebito.setEditable(false);
                } catch (Exception ex) {
                    bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                            + " separando os centavo por ponto (`.`)</html>");
                    bl.setLocationRelativeTo(null);
                    bl.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_jTextFieldDebitoKeyPressed

    private void jTextFieldCreditoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCreditoKeyPressed
        if (jTextFieldCredito.isEditable() == true) {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                try {
                    double pegar = Double.valueOf(jTextFieldCredito.getText());
                    contas(pegar);
                    jTextFieldCredito.setEditable(false);
                } catch (Exception ex) {
                    bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                            + " separando os centavo por ponto (`.`)</html>");
                    bl.setLocationRelativeTo(null);
                    bl.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_jTextFieldCreditoKeyPressed

    private void jTextFieldDinheiroFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDinheiroFocusLost
        if (jTextFieldDinheiro.isEditable() == true) {
            try {
                double pegar = Double.valueOf(jTextFieldDinheiro.getText());
                contas(pegar);
                jTextFieldDinheiro.setEditable(false);
            } catch (Exception ex) {
                bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                        + " separando os centavo por ponto (`.`)</html>");
                bl.setLocationRelativeTo(null);
                bl.setVisible(true);
            }
        }
    }//GEN-LAST:event_jTextFieldDinheiroFocusLost

    private void jTextFieldChequeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldChequeFocusLost
        if (jTextFieldCheque.isEditable() == true) {
            try {
                double pegar = Double.valueOf(jTextFieldCheque.getText());
                contas(pegar);
                jTextFieldCheque.setEditable(false);
            } catch (Exception ex) {
                bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                        + " separando os centavo por ponto (`.`)</html>");
                bl.setLocationRelativeTo(null);
                bl.setVisible(true);
            }
        }
    }//GEN-LAST:event_jTextFieldChequeFocusLost

    private void jTextFieldDebitoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldDebitoFocusLost
        if (jTextFieldDebito.isEditable() == true) {
            try {
                double pegar = Double.valueOf(jTextFieldDebito.getText());
                contas(pegar);
                jTextFieldDebito.setEditable(false);
            } catch (Exception ex) {
                bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                        + " separando os centavo por ponto (`.`)</html>");
                bl.setLocationRelativeTo(null);
                bl.setVisible(true);
            }

        }
    }//GEN-LAST:event_jTextFieldDebitoFocusLost

    private void jTextFieldCreditoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldCreditoFocusLost
        if (jTextFieldCredito.isEditable() == true) {
            try {
                double pegar = Double.valueOf(jTextFieldCredito.getText());
                contas(pegar);
                jTextFieldCredito.setEditable(false);
            } catch (Exception ex) {
                bloqueio bl = new bloqueio(null, true, "<html> Por favor, adicione apenas números neste campo,"
                        + " separando os centavo por ponto (`.`)</html>");
                bl.setLocationRelativeTo(null);
                bl.setVisible(true);
            }
        }
    }//GEN-LAST:event_jTextFieldCreditoFocusLost

    public static void main(String args[]) {

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(fecharVenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(fecharVenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(fecharVenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(fecharVenda.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                fecharVenda dialog = new fecharVenda(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonApagarCheque;
    private javax.swing.JButton jButtonApagarCredito;
    private javax.swing.JButton jButtonApagarDebito;
    private javax.swing.JButton jButtonApagarDinheiro;
    private javax.swing.JButton jButtonCancelarCadastro;
    private javax.swing.JButton jButtonConcluir;
    private javax.swing.JButton jButtonLimparDados;
    private javax.swing.JLabel jLabelMsg10;
    private javax.swing.JLabel jLabelMsg18;
    private javax.swing.JLabel jLabelMsg2;
    private javax.swing.JLabel jLabelMsg3;
    private javax.swing.JLabel jLabelMsg4;
    private javax.swing.JLabel jLabelMsg5;
    private javax.swing.JLabel jLabelMsg7;
    private javax.swing.JLabel jLabelMsg8;
    public static javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    public static javax.swing.JTextField jTextFieldCheque;
    public static javax.swing.JTextField jTextFieldCredito;
    public static javax.swing.JTextField jTextFieldDebito;
    public static javax.swing.JTextField jTextFieldDinheiro;
    public static javax.swing.JTextField jTextFieldFalta;
    public static javax.swing.JTextField jTextFieldRecebido;
    public static javax.swing.JTextField jTextFieldTotal;
    public static javax.swing.JTextField jTextFieldTroco;
    // End of variables declaration//GEN-END:variables
}
